﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ModularFixture.CUiMFSelectCompoundResourceDlg
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.ComponentModel;
using System.Drawing;
using System.Resources;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;
using Tecnomatix.Planning;


namespace DnProcessSimulateCommands.ModularFixture;

public class CUiMFSelectCompoundResourceDlg : TxForm
{
  private CApMFAdministratorManager m_adminManager;
  private IContainer components;
  private Label label1;
  private TxObjEditBoxCtrl m_resource;
  private Button m_ok;
  private Button m_cancel;

  public CUiMFSelectCompoundResourceDlg(CApMFAdministratorManager adminManager)
  {
    this.InitializeComponent();
    this.m_adminManager = adminManager;
  }

  private void CUiMFSelectCompoundResourceDlg_Load(object sender, EventArgs e)
  {
    this.m_resource.SetValidator((ITxValidator) new TxTypeFilterValidator((ITxTypeFilter) new TxTypeFilter(typeof (TxCompoundResource))));
    this.m_resource.ListenToPick = true;
    this.m_resource.Focus();
    this.m_ok.Enabled = false;
  }

  private void m_ok_Click(object sender, EventArgs e)
  {
    ((Form) this).Close();
    Cursor current = Cursor.Current;
    Cursor.Current = Cursors.WaitCursor;
    if ((((this.m_resource.Object as TxCompoundResource).PlanningRepresentation as TxPlanningObject).PlatformServicesProvider as TxEmsServicesProvider).InternalId == 0)
    {
      ResourceManager resourceManager = new ResourceManager("ModularFixture.ConfigurationAdministrator.Res.StringTable", ((object) this).GetType().Assembly);
      int num = (int) TxMessageBox.Show(resourceManager.GetString("COMPOUND_RESOURCE_DOESNT_EXIST_IN_EMS_MESSAGE"), resourceManager.GetString("CMD_CONFIGURATION_ADMINISTRATOR_NAME"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
    }
    else
      this.m_adminManager.LoadFromCompoundResource((TxCompoundResource) this.m_resource.Object);
    Cursor.Current = current;
  }

  private void m_cancel_Click(object sender, EventArgs e) => ((Form) this).Close();

  private void m_resource_TypeInvalid(object sender, EventArgs e) => this.m_ok.Enabled = false;

  private void m_resource_Picked(object sender, TxObjEditBoxCtrl_PickedEventArgs args)
  {
    this.m_ok.Enabled = true;
  }

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CUiMFSelectCompoundResourceDlg));
    this.label1 = new Label();
    this.m_resource = new TxObjEditBoxCtrl();
    this.m_ok = new Button();
    this.m_cancel = new Button();
    ((Control) this).SuspendLayout();
    this.label1.AutoSize = true;
    this.label1.Location = new Point(12, 11);
    this.label1.Name = "label1";
    this.label1.Size = new Size(87, 13);
    this.label1.TabIndex = 0;
    this.label1.Text = "Resource Name:";
    this.m_resource.ListenToPick = false;
    ((Control) this.m_resource).Location = new Point(12, 30);
    ((Control) this.m_resource).Name = "m_resource";
    this.m_resource.Object = (ITxObject) null;
    this.m_resource.PickLevel = (TxPickLevel) 1;
    this.m_resource.ReadOnly = false;
    ((Control) this.m_resource).Size = new Size(243, 20);
    ((Control) this.m_resource).TabIndex = 1;
    this.m_resource.ValidatorType = (TxValidatorType) 1;
    this.m_resource.TypeInvalid += new EventHandler(this.m_resource_TypeInvalid);
    this.m_resource.Picked += new TxObjEditBoxCtrl_PickedEventHandler(this.m_resource_Picked);
    this.m_ok.DialogResult = DialogResult.OK;
    this.m_ok.Location = new Point(99, 61);
    this.m_ok.Name = "m_ok";
    this.m_ok.Size = new Size(75, 23);
    this.m_ok.TabIndex = 2;
    this.m_ok.Text = "OK";
    this.m_ok.UseVisualStyleBackColor = true;
    this.m_ok.Click += new EventHandler(this.m_ok_Click);
    this.m_cancel.DialogResult = DialogResult.Cancel;
    this.m_cancel.Location = new Point(180, 61);
    this.m_cancel.Name = "m_cancel";
    this.m_cancel.Size = new Size(75, 23);
    this.m_cancel.TabIndex = 3;
    this.m_cancel.Text = "Cancel";
    this.m_cancel.UseVisualStyleBackColor = true;
    this.m_cancel.Click += new EventHandler(this.m_cancel_Click);
    ((Form) this).AcceptButton = (IButtonControl) this.m_ok;
    ((ContainerControl) this).AutoScaleDimensions = new SizeF(6f, 13f);
    ((ContainerControl) this).AutoScaleMode = AutoScaleMode.Font;
    ((Form) this).CancelButton = (IButtonControl) this.m_cancel;
    ((Form) this).ClientSize = new Size(267, 92);
    ((Control) this).Controls.Add((Control) this.m_cancel);
    ((Control) this).Controls.Add((Control) this.m_ok);
    ((Control) this).Controls.Add((Control) this.m_resource);
    ((Control) this).Controls.Add((Control) this.label1);
    ((Form) this).FormBorderStyle = FormBorderStyle.FixedDialog;
    ((Form) this).Icon = (Icon) componentResourceManager.GetObject("$this.Icon");
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CUiMFSelectCompoundResourceDlg);
    ((Form) this).ShowIcon = false;
    ((Control) this).Text = "Select Compound Resource";
    ((Form) this).TopMost = true;
    ((Form) this).Load += new EventHandler(this.CUiMFSelectCompoundResourceDlg_Load);
    ((Control) this).ResumeLayout(false);
    ((Control) this).PerformLayout();
  }
}
